﻿@model List<PartyManagement.Models.FoodInMenu>
@{
    ViewBag.Title = "Menu";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

@if (Model.Count == 0)
{
    <p>No food in your menu, please choose some food in @Html.ActionLink("here", "GetFoodList", "Food")</p>
}

else
{
    using (Html.BeginForm())
    {
    <table style="width: 700px;">
        <tr>
            <th style="width: 35%;">Food name</th>
            <th>Quantity Available</th>
            <th style="width: 15%">Quantity</th>
            <th style="width: 40%">&nbsp;</th>
        </tr>
        @foreach (var item in Model)
        {
            <tr>
                <td>@item.Food.foodName</td>
                <td>@item.Food.quantity</td>
                <td>
                    <input type="text" value="@item.quantity" name="quantity"/>
                    <input type="hidden" value="@item.foodInMenuID" name="foodId"/>
                </td>
                <td>@Html.ActionLink("Remove from Menu", "DeleteFromMenu", "Menu", new { id = item.foodInMenuID }, null)</td>
            </tr>
        }
    </table>
    <input type="submit" value="Update" id="update" />
    }
    
    <p>You can get more food/juice in @Html.ActionLink("here", "GetFoodList", "Food")</p>
}

<script>
    $("#chkAll").click(function () {
        var checked = $(this).is(':checked');
        $(".chkCheck").attr("checked", checked);
    });
    $(".chkCheck").click(function () {
        var valid = true;
        $(".chkCheck").each(function () {
            var checked = $(this).is(':checked');
            if (!checked) {
                valid = false;
            }
        });
        $("#chkAll").attr("checked", valid);
    });
</script>

